<?php

namespace app\admin\validate;

use think\Validate;

class MenuValidate extends Validate
{
    protected $message = [
        'id.require' => 'ID必须填写',
        'id.integer' => 'ID必须为整数',
        'parent_id.integer' => '父级ID必须为整数',
        'name.require' => '菜单名称必须填写',
        'name.max' => '菜单名称最多不能超过50个字符',
        'path.max' => '路由路径最多不能超过100个字符',
        'component.max' => '组件路径最多不能超过100个字符',
        'icon.max' => '图标最多不能超过50个字符',
        'permission.max' => '权限标识最多不能超过50个字符',
        'type.require' => '类型必须填写',
        'type.in' => '类型值错误',
        'method.max' => '请求方法最多不能超过10个字符',
        'status.in' => '状态值错误',
        'sort.integer' => '排序必须为整数',
        'page.integer' => '页码必须为整数',
        'page.egt' => '页码必须大于等于1',
        'limit.integer' => '每页数量必须为整数',
        'limit.between' => '每页数量只能在1到100之间',
    ];
    
    protected $group = [
        'index' => [
            'page' => 'integer|egt:1',
            'limit' => 'integer|between:1,100',
            'name' => 'max:50',
            'status' => 'integer|in:0,1',
        ],
        'info' => [
            'id' => 'require|integer',
        ],
        'create' => [
            'parent_id' => 'integer',
            'name' => 'require|max:50',
            'path' => 'max:100',
            'component' => 'max:100',
            'icon' => 'max:50',
            'permission' => 'max:50',
            'type' => 'require|in:menu,button,api',
            'method' => 'max:10',
            'status' => 'in:0,1',
            'sort' => 'integer',
        ],
        'update' => [
            'id' => 'require|integer',
            'parent_id' => 'integer',
            'name' => 'max:50',
            'path' => 'max:100',
            'component' => 'max:100',
            'icon' => 'max:50',
            'permission' => 'max:50',
            'type' => 'in:menu,button,api',
            'method' => 'max:10',
            'status' => 'in:0,1',
            'sort' => 'integer',
        ],
        'delete' => [
            'id' => 'require|integer',
        ],
    ];
}